// 动态加载数据
function loadData() {
    const contentElement = document.getElementById('dynamic-content');
    contentElement.innerHTML = '正在从服务器加载数据...';
    
    fetch('/api/hello')
        .then(response => response.json())
        .then(data => {
            contentElement.innerHTML = ;
        })
        .catch(error => {
            contentElement.innerHTML = ;
        });
}

// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
    console.log('Spring Boot Web 应用已加载');
    
    // 显示欢迎信息
    const contentElement = document.getElementById('dynamic-content');
    contentElement.innerHTML = '欢迎使用 Spring Boot Web 应用！点击按钮与服务器交互。';
    
    // 添加一些交互效果
    const cards = document.querySelectorAll('.card');
    cards.forEach(card => {
        card.addEventListener('mouseenter', function() {
            this.style.transform = 'translateY(-5px)';
            this.style.transition = 'transform 0.3s ease';
        });
        
        card.addEventListener('mouseleave', function() {
            this.style.transform = 'translateY(0)';
        });
    });
});
